/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ListCustomerPhone extends AbstractAction
/*    */ {
/* 32 */   private static Logger logger = Logger.getLogger(ListCustomerPhone.class
/* 33 */     .getName());
/*    */ 
/*    */   public ListCustomerPhone(AbstractHttpServlet servlet)
/*    */   {
/* 36 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 42 */     response.setContentType("text/html;charset=utf-8");
/* 43 */     PrintWriter out = response.getWriter();
/* 44 */     int customerId = Util.getURLIntParameter(request
/* 45 */       .getParameter("customerId"));
/*    */ 
/* 47 */     if (customerId <= 0) {
/* 48 */       super.showErrorMessage(response, "");
/* 49 */       return;
/*    */     }
/*    */ 
/* 52 */     CustomerManager manager = new CustomerManager();
/* 53 */     JSONObject jsonObject = new JSONObject();
/*    */     try
/*    */     {
/* 56 */       List peoples = manager
/* 57 */         .getPeoplesMiniInfo(customerId);
/*    */ 
/* 59 */       StringBuffer customerIds = new StringBuffer();
/* 60 */       customerIds.append(customerId);
/* 61 */       if (peoples != null) {
                for (Object peopleO : peoples) {
                    Map people = (Map)peopleO;
/* 63 */           customerIds.append(",").append(people.get("CustomerId"));
/*    */         }
/*    */ 
/*    */       }
/*    */ 
/* 68 */       List result = manager
/* 69 */         .getCustomerPhone(customerIds.toString());
/* 70 */       if (result == null) {
/* 71 */         jsonObject.put("error", "1");
/*    */       } else {
/* 73 */         jsonObject.put("error", "0");
/* 74 */         jsonObject.put("peoples", peoples);
/* 75 */         jsonObject.put("customerPhone", result);
/*    */       }
/*    */     } catch (DBException e) {
/* 78 */       logger.warn("DBException", e);
/* 79 */       jsonObject.put("error", "1");
/*    */     } catch (SQLException e) {
/* 81 */       logger.warn("SQLException", e);
/* 82 */       jsonObject.put("error", "1");
/*    */     }
/* 84 */     out.println(jsonObject);
/* 85 */     out.flush();
/* 86 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ListCustomerPhone
 * JD-Core Version:    0.6.1
 */